package handler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.ResultSetHandler;

import drh.bean.Address;
import drh.bean.Order;

public class OrderResultSetHandler implements ResultSetHandler<List<Order>> {

	@Override
	public List<Order> handle(ResultSet rs) throws SQLException {
		List<Order>list = new ArrayList<>();
		while(rs.next()) {
			Order info = new Order();
			info.setId(rs.getInt("id"));
			info.setOrderuid(rs.getString("orderuid"));
			info.setState(rs.getString("state"));
			info.setPayway(rs.getInt("payway"));
			info.setUserid(rs.getInt("userid"));
			info.setAddressid(rs.getInt("addressid"));
			info.setMessage(rs.getString("message"));
			info.setMoney(rs.getInt("money"));
			info.setTime(rs.getDate("time"));
			info.setIsdelete(rs.getInt("isdelete"));
			info.setIntegral(rs.getInt("integral"));
//			Address ainfo = new Address();
//			ainfo.setAddress(rs.getString("address"));
//			ainfo.setId(rs.getInt("aid"));
//			ainfo.setUserid(rs.getInt("auserid"));
//			ainfo.setConsignee(rs.getString("consignee"));
//			info.setAinfo(ainfo);
			list.add(info);		
		}
		return list;
	}

}
